//
//  LYQMineAccountInfoViewController.m
//  ZCProject
//
//  Created by Zheng on 16/11/18.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQMineAccountInfoViewController.h"
#import "LYQLoginSettingPasswordViewController.h"
#import "LYQSettingsChangeNumberViewController.h"

#import "LYQMineAccountInfoCell.h"

#define kLYQMineAccountInfoCell_ID @"kLYQMineAccountInfoCell_ID"

@interface LYQMineAccountInfoViewController () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) NSArray *titleNamesArr;

@end

@implementation LYQMineAccountInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"账号信息";
    
    self.listTableView.dataSource = self;
    self.listTableView.delegate = self;
    self.listTableView.scrollEnabled = NO;
    [self.listTableView registerClass:[LYQMineAccountInfoCell class] forCellReuseIdentifier:kLYQMineAccountInfoCell_ID];
    
    _titleNamesArr = @[@"修改手机号",@"修改密码"];
    
}

#pragma mark - tableview datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    LYQMineAccountInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:kLYQMineAccountInfoCell_ID forIndexPath:indexPath];
    
    cell.textLabel.text = _titleNamesArr[indexPath.row];
    
    if (indexPath.row == 0) {
        cell.phoneLbl.text = @"13512344321";
    }
    
    return cell;
}

#pragma mark - tableview delegate
#pragma mark 头视图高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return kWScale(10.5);
}

#pragma mark 单元格高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kWScale(50);
}

#pragma mark 设置分割线偏移量
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsMake(0, kWScale(10), 0, 0)];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsMake(0, kWScale(10), 0, 0)];
    }
}

#pragma mark 单元格点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
#pragma mark 跳转到修改手机号界面
        LYQSettingsChangeNumberViewController *scnVC = [[LYQSettingsChangeNumberViewController alloc] init];
        [self.navigationController pushViewController:scnVC animated:YES];
    } else {
#pragma mark 跳转到修改密码页面
        LYQLoginSettingPasswordViewController *lspVC = [[LYQLoginSettingPasswordViewController alloc] init];
        lspVC.navigationItem.title = @"修改密码";
        [self.navigationController pushViewController:lspVC animated:YES];
    }
}

#pragma mark - 内存警告
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
